import { DataTypes } from 'sequelize';
import seq from '../db/seq';
import moment from 'moment';

/**字典类型 */
const DictType = seq.define('dict_type', {
    name: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: true,
        comment: '字典类型名称,需唯一'
    },
    code: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: true,
        comment: '字典类型编码，需唯一'
    },
}, {
    tableName: 'dict_type',
    createdAt: 'createTime',
    updatedAt: 'updateTime'
})

/**字典数据 */
const DictData = seq.define('dict_data', {
    dict_label: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: false,
        comment: '字典标签'
    },
    dict_code: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: false,
        comment: '字典编码，关联字典类型'
    },
    dict_value: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: false,
        comment: '字典值'
    },
    dict_color:{
        type: DataTypes.STRING,
        allowNull: false,
        unique: false,
        defaultValue:'default',
        comment: '字典值对应的颜色，主要用于标签使用 默认default'
    }
}, {
    tableName: 'dict_data',
    createdAt: "createTime",
    updatedAt: "updateTime",
})

// DictType.sync({force:true});
// DictData.sync({force:true});
export default {
    DictType,
    DictData
};
